<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>
        列表
    </title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../css/bootstrap.css">
    <link rel="stylesheet" href="../../../lib/layui/css/layui_2.5.7.css">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .layui-table-page select {
            height: 22px;
        }
    </style>
</head>
<style>
    input {
        width: 280px !important;
    }
</style>
<body>

<div id="settings">
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>个人设置</cite></a>
            <a><cite>修改密码</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
    </div>
    <div class="fly-panel">
        <div class="fly-none" style="text-align: -webkit-center">

            <span style="width: 48%; height: 450px; border: 1px solid #00bcd4; display: block;padding: 10%;min-width: 500px;margin-top: 2%">

                <div id="app" class="layui-fluid">
                    <div class="layui-row">
                        <form class="layui-form">
                            <div class="layui-form-item">
                                <label for="oldPwd" class="layui-form-label">
                                    <span class="x-red">*</span>旧密码
                                </label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  type="password" v-model="oldPwd" id="oldPwd" name="oldPwd" required=""
                                           lay-verify="required"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="newPwd" class="layui-form-label">
                                    <span class="x-red">*</span>新密码
                                </label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  v-model="newPwd" type="password" id="newPwd"
                                           name="newPwd"
                                           lay-verify="required"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="finalNewPwd" class="layui-form-label">
                                    <span class="x-red">*</span>确认密码
                                </label>
                                <div class="layui-input-inline">
                                    <input  autocomplete="off"  v-model="finalNewPwd" type="password" id="finalNewPwd"
                                           name="finalNewPwd"
                                           lay-verify="required"
                                           autocomplete="off" class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item" style="text-align: center">
                                <button class="layui-btn" @click.prevent="sub">
                                    修改
                                </button>
                            </div>
                        </form>
                    </div>
                </div>

            </span>
            <p><h5><b>用户密码管理</b></h5></p>
        </div>
    </div>
    <br><br><br><br><br>
</div>

<script type="text/javascript" src="../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../js/pub.js"></script>
<script type="text/javascript" src="../../../lib/layui/layui2.5.7.js"></script>
<script type="text/javascript" src="../../../js/vue.min.js"></script>
<!-- <script src="lib/layui/layui.js" charset="utf-8"></script> -->
<script src="../../../js/x-layui.js" charset="utf-8"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer', 'form'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element;//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        var form = layui.form;
        okLoading.close($);
    });
</script>
<script>

    const vm = new Vue({
        el: "#settings",
        data: {
            oldPwd: '',
            newPwd: '',
            finalNewPwd: ''
        },
        methods: {
            sub() {
                if ((vm.oldPwd.length < 6) || (vm.oldPwd.length < 6) || (vm.finalNewPwd.length < 6)) {
                    layer.alert("密码不能小于6位!");
                    return false;
                }
                if (this.newPwd != this.finalNewPwd) {
                    layer.alert("两次输入密码不一致!");
                    return false;
                }
                let request = {
                    url: "user/updUserPwd",
                    data: {
                        userId: $userId,
                        oldPwd: this.oldPwd,
                        newPwd: this.finalNewPwd
                    },
                    method: 'post'
                };
                sendRequest(request, (data) => {
                    if (data.code === 0) {
                        layer.alert("修改成功", {
                            icon: 6
                        });
                        this.oldPwd = null;
                        this.newPwd = null;
                        this.finalNewPwd = null;

                    } else {
                        layer.alert(data.msg, {
                            icon: 5
                        })
                    }
                    // console.log(data)
                })
            }
        }
    })

</script>
</body>
</html>
